Source code for /engineering/webperf/master-v2[j1.2]/SessionLog.javaOriginal file SessionLog.java
   1 import java.util.*;
   2 
   3 public class SessionLog {
   4    
   5    ObjectMonitor   myLock; 
   6    StringBuffer	 log;
   7    long		 start; 
   8    long		 pause;
   9 
  10    SessionLog() {
  11 	myLock    = new ObjectMonitor();
  12       log       = new StringBuffer(10000);  //  initial capacity = 10000 chars
  13 	start	    = 0;
  14    }
  15 
  16    public String get() {
  17 
  18 	String tempLog;
  19 
  20       myLock.lock(true);
  21 	tempLog = log.toString();     
  22       myLock.lock(false);
  23 
  24       return tempLog;
  25    }
  26    
  27    public void post(String entry) {
  28       
  29 	long	myTime;
  30 
  31 	myLock.lock(true);
  32 
  33    	Date	 time = new Date(); 
  34 
  35 	myTime = getTiming();
  36 	log.append( myTime + " : " + entry + "\n");
  37 
  38       myLock.lock(false);
  39    }     
  40 
  41    public void clear() {
  42 
  43       myLock.lock(true);
  44 	log.setLength(0);
  45       myLock.lock(false);
  46 
  47    }
  48 
  49    public void startTiming() {
  50 
  51 	Date	 time = new Date(); 
  52 	start = time.getTime();	
  53    }
  54 
  55    public void stopTiming() {
  56 	start = 0;
  57    }
  58    
  59    public void pauseTiming() {
  60    	Date	 time = new Date(); 
  61 	pause = time.getTime();	
  62    }
  63 
  64    public void resumeTiming() {
  65    	Date	 time = new Date(); 
  66 	start = time.getTime() - (pause-start);
  67    }
  68 
  69 
  70    public long getTiming() {
  71    	Date	 time = new Date();
  72 	long  current;
  73 	if (start > 0)
  74 	   current = time.getTime() - start;
  75 	else
  76   	   current = 0;
  77 	return current;
  78    }
  79 
  80    public long getRaw() {
  81    	Date	 time = new Date();
  82 	long  current;
  83       current = time.getTime();
  84 	return current;
  85    }
  86 
  87 }